﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Admin.Master" Inherits="System.Web.Mvc.ViewPage<IEnumerable<Hotnet.Entity.Tag>>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
	Tag管理
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
	<h2>Tag管理</h2>
	
	<table width="100%" class="ma list">
		<tr>
			<%Html.BeginForm("Index","AdminTag"); %>
			<td>Tag名称:</td>
			<td>
				<%=Html.TextBox("TagName") %>
			</td>
			<td>Tag类型:</td>
			<td>
				<%=Html.DropDownList("TargetType", ConvertEnumToSelectList.ComposeSelectListFromEnum<EnumTagType>("全部类型","")) %>
			</td>
			<td>排序:</td>
			<td>
				<%=Html.DropDownList("TagCountType", ConvertEnumToSelectList.ComposeSelectListFromEnum<EnumTagCountType>())%>
			</td>
			<td>
				<input type="submit" value="搜索" />
			</td>
			<%Html.EndForm(); %>
		</tr>
	
	</table>
	
	<table width="100%" class="ma list">
		<tr>
			<th>
				TagID
			</th>
			<th>
				Tag名称
			</th>
			<th>
				Tag类型
			</th>
			<th>
				点击次数
			</th>
			<th>
				引用次数
			</th>
			<th>
				添加时间
			</th>
			<th>
				操作
			</th>
		</tr>
		<% foreach (var item in Model)
	 { %>
		<tr>
			<td>
				<%= Html.Encode(item.TagID) %>
			</td>
			<td>
				<%= Html.Encode(item.TagName) %>
			</td>
			<td>
				<%= Html.Encode(((EnumTagType)item.TargetType)).ToString() %>
			</td>
			<td>
				<%= Html.Encode(item.ClickCount) %>
			</td>
			<td>
				<%= Html.Encode(item.RefCount) %>
			</td>
			<td>
				<%= Html.Encode(String.Format("{0:g}", item.AddTime)) %>
			</td>
			<td style=" text-align:center">
				<a href="javascript:editTag(<%=item.TagID %>, '<%=item.TagName%>',<%=item.TargetType %>)">编辑</a> |
				<a href="javascript:confirmDelete('确定删除此Tag?', '/AdminTag/Delete/', <%=item.TagID %>);">删除</a> 
			</td>
		</tr>
		<% } %>
	</table>
		<%Html.RenderPartial("PaginateHelper", ViewData["PaginateHelper"] as PaginateHelper); %>
	<p>
		<a href="javascript:newTag();" class="btn">新增Tag</a>
	</p>
	
	<div id="createWindow" style="display:none;">
		<%using (Html.BeginForm("Create", "AdminVideoCategory", FormMethod.Post, new { id="formMutiple"}))
		{%>
		<input type="hidden" name="tagID" id="tagID" />
		<div class="tac ma">
			<span class="mr3">Tag名称:</span>
			<input type="text" name="tagName" id="tagName" />
		</div>
		<div style=" margin-left:49px; margin-top:5px;">
			<span class="mr3">Tag类型:</span>
			<%=Html.DropDownList("targetType", ConvertEnumToSelectList.ComposeSelectListFromEnum<EnumTagType>()) %>
		</div>
		<div style="text-align:center; margin-top:10px;">
			<input type="submit" value="确定" class="ml3 boxy-button" />
			<input type="button" value="关闭" class="ml3 boxy-button" onclick="closeWindow();" />
		</div>
		<% } %>
	</div>
	
	<script type="text/javascript">
		var boxy;
		function showWindow() {
			if (boxy == null)
				boxy = new Boxy($('#createWindow'), { modal: false, title: '新增Tag', closeText: '[×]', draggable: true }).resize(310, 80);
			else
				boxy.show();
		}
		function closeWindow() {
			boxy.hide();
		}

		function newTag() {
			$("#formMutiple").attr("action", "/AdminTag/Create");
			$("#tagName").val("");
			$("#tagID").val("");

			showWindow();
			boxy.setTitle("新增Tag");
		}

		function editTag(tagId, name,targetType) {
			$("#formMutiple").attr("action", "/AdminTag/Edit");
			$("#tagID").val(tagId);
			$("#tagName").val(name);
			$("#targetType").val(targetType);

			showWindow();
			boxy.setTitle("编辑Tag");
		}
	
	</script>
	
	
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="ScriptContent" runat="server">
</asp:Content>
<asp:Content ID="Content4" ContentPlaceHolderID="StyleContent" runat="server">
</asp:Content>
